package ar.edu.utn.frgp.jdbctest;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public final class ConfigurationReader {
	
	private static Properties props;
	
	private static ConfigurationReader reader;
	
	private ConfigurationReader() {
		props = new Properties();
		InputStream inStream = null;
		try {

			inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ConfDB.properties");
			
			props.load(inStream);
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(inStream != null)
				try {
					inStream.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
	}
	
	
	public static ConfigurationReader configuration(){
		if(reader == null)reader = new ConfigurationReader();
		return reader;
	}
	
	public String getValue(String key){
		return props.getProperty(key);
	}

}
